package com.helloae;

import java.io.File;

import com.esri.arcgis.carto.FeatureLayer;
import com.esri.arcgis.carto.IFeatureLayer;
import com.esri.arcgis.datasourcesfile.ShapefileWorkspaceFactory;
import com.esri.arcgis.geodatabase.IFeatureClass;
import com.esri.arcgis.geodatabase.IFeatureClassProxy;
import com.esri.arcgis.geodatabase.IFeatureWorkspace;
import com.esri.arcgis.geodatabase.IFeatureWorkspaceProxy;
import com.esri.arcgis.geodatabase.IQueryFilter;
import com.esri.arcgis.geodatabase.IWorkspaceFactory;
import com.esri.arcgis.geodatabase.QueryFilter;
import com.esri.arcgis.system.AoInitialize;
import com.esri.arcgis.system.EngineInitializer;
import com.esri.arcgis.system.esriLicenseProductCode;

public class EngineHelloWorld {

	public static void main(String[] args) throws Exception {
		EngineInitializer.initializeEngine();
		AoInitialize ao = new AoInitialize();
		ao.initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);
		
		IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory();
		IFeatureWorkspace pFeatureWorkspace = new IFeatureWorkspaceProxy(pWorkspaceFactory.openFromFile("DataSet"+File.separator+"other", 0));
		IFeatureClass pFeatureClass = new IFeatureClassProxy(pFeatureWorkspace.openFeatureClass("陕西地级城市驻地"));
		IFeatureLayer pFeatureLayer = new FeatureLayer();
		pFeatureLayer.setFeatureClassByRef(pFeatureClass);
		pFeatureLayer.setName(pFeatureLayer.getFeatureClass().getAliasName());
		IFeatureClass pFeatureClass2 = pFeatureLayer.getFeatureClass();
		IQueryFilter pQueryFilter = new QueryFilter();
		String whereClause = "\"FID\" > 5";
		pQueryFilter.setWhereClause(whereClause);
		System.out.println(pFeatureClass2.featureCount(pQueryFilter));
		
		ao.shutdown();
		System.out.println("Congratulations!");
	}

}
